/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import entities.InforContact;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author hungpm_b01223
 */
public class getInforContact {
    ConnectDB myConn = new ConnectDB();
    Connection conn;
    
    public InforContact getListInforContact(String user){
        InforContact ifc = null;
        try {
            conn = myConn.getConnect();
            Statement stmt  = conn.createStatement();
            String sql = "select * from InforContact,NhaTuyenDung where Id=(select id from userName where account='"+user+"') AND InforContact.InforID=NhaTuyenDung.InforID";
            ResultSet rs = stmt.executeQuery(sql);
            while(rs.next()){
                ifc.setInforID(rs.getInt(1));
                ifc.setContactName(rs.getString(2));
                ifc.setContactAddress(rs.getString(3));
                ifc.setContactEmail(rs.getString(4));
                ifc.setContactphone(rs.getString(5));              
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ifc;
    }
    public int layIdCont(String user){
        int id=0;
        String qr="select InforID from NhaTuyenDung where id=(select id from userName where account='"+user+"')";
        try {
            conn=myConn.getConnect();
            Statement stmt  = conn.createStatement();
            ResultSet rs = stmt.executeQuery(qr);
            while(rs.next()){
                id=rs.getInt(1);
            }
        } catch (Exception e) {
        }
        return id;
    }
}
